#ifndef MODELPLAYLISTS_H
#define MODELPLAYLISTS_H

#include <QAbstractTableModel>

#include "playlist.h"

class ModelPlaylists : public QAbstractTableModel
{
    Q_OBJECT
    Q_DISABLE_COPY(ModelPlaylists)

public:
    explicit ModelPlaylists(QObject *parent = 0);
    ~ModelPlaylists();

    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
    virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    virtual QVariant headerData(int section, Qt::Orientation orientation,
                                int role = Qt::DisplayRole) const;

    bool addFile(const QString& i_filepath, const QHash<QString, AudioFile *> &i_audioFiles);
    bool addNewFile(const QString& i_filepath);
    void remove(int i_idx);
    void clear();
    void setReplacePath(const QString& i_path, const QHash<QString, AudioFile *> &i_audioFiles);
    void setLocalPath(const QString& i_path, const QHash<QString, AudioFile *> &i_audioFiles);

    inline const QList<Playlist*>& lists() const {return m_lists;}

signals:
    void countChanged(int);

private:
    void checkAudioFiles(const QHash<QString, AudioFile *> &i_audioFiles);

private slots:
    void playlistChanged();

private:
    enum ColumnIndex
    {
        Filename,
        NoOfSongs,
        Missing,
        Duplicate,
        Incomplete,
        Type,
        MaxColIdx,
    };

    QList<Playlist*> m_lists;

    static const QBrush MISSING_BRUSH;
    static const QBrush DUPLICATE_BRUSH;
    static const QBrush INCOMPLETE_BRUSH;
    static QIcon DEFAULT_ICON;
    static QFont CHANGED_FONT;
};

#endif // MODELPLAYLISTS_H
